#include <iostream>
#include <string>

using namespace std;

class Solution
{
public:
    int minSwaps(string s)
    {
        int result = -1;
        // start =1
        bool lastCharIs1 = true;
        int waitSwap1 = 0, waitSwap0 = 0;
        for (auto i : s)
        {
            if (lastCharIs1 && i == '1')
                waitSwap1++;
            else if (!lastCharIs1 && i == '0')
                waitSwap0++;
            lastCharIs1 = !lastCharIs1;
        }
        if (waitSwap1 == waitSwap0)
        {
            result = waitSwap1;
        }

        lastCharIs1 = false;
        waitSwap1 = 0, waitSwap0 = 0;
        for (auto i : s)
        {
            if (lastCharIs1 && i == '1')
                waitSwap1++;
            else if (!lastCharIs1 && i == '0')
                waitSwap0++;
            lastCharIs1 = !lastCharIs1;
        }
        if (waitSwap1 == waitSwap0)
        {
            if (result == -1)
                result = waitSwap1;
            else
                result = min(result, waitSwap1);
        }
        return result;
    }
};
int main()
{
    cout << "Code1864" << endl;
    Solution s;
    cout << s.minSwaps("1") << endl;
    return 0;
}